home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Prograph Classic 2.6.1 / Learning Prograph / SysClass Examples ƒ / SysClass Examples.ReadMe < prev   
Encoding:
Text File  |  1994-10-21  |  14.4 KB  |  223 lines  |  [TEXT/ttxt]

  1. Example:      SysClass Examples ƒ
  2. Written by:  Prograph International (Lynn McKaig)
  3. Contents:     SysClass Examples.pgs
  4.                    SysClass Examples.ReadMe
  5.  
  6. Needs Prograph Extensions:
  7.                    Math Primitives
  8.                    More Primitives
  9.                    Primitives
  10.  
  11. Needs Libraries to Compile:
  12.                    SCLibrary 2.6
  13.                    Library 2.6
  14.  
  15. Description
  16. -----------
  17. The "SysClass Examples.pgs" file contains the System Classes and a number of subclasses of the Window class.  Each subclass is a window that illustrates the features of a particular system class (such as Check Box).  Each class contains methods that illustrate how to do simple but useful things with the System Class in question (e.g., check a check box, or change the font in a text item).
  18.  
  19. Select Run from the Exec menu and open the various example windows in turn.  To see the click method of any window item or menu item, shift-option-cmd-click on it while the application is running.  This is a good way to start exploring this example.
  20.  
  21. CLASS: Window Examples
  22.  
  23. • open from library
  24. Executed when you select "Window (from library)" from the Examples menu.  Shows you how to find a window that already exists in the application's library and open it.
  25.  
  26. • open from class
  27. Executed when you select "Window (from class)" from the Examples menu.  Shows you how to create a new window instance and open it.
  28.  
  29. • close button
  30. Executed when you click on the Close button in the Window Examples window.  Closes the window.
  31.  
  32. • move left
  33. Executed when you click on the Left button in the Window Examples window.  Moves the window to the left by setting the location attribute.
  34.  
  35. • move right
  36. Executed when you click on the Right button in the Window Examples window.  Moves the window to the right by setting the location attribute.
  37.  
  38. • make bigger
  39. Executed when you click on the Bigger button in the Window Examples window.  Makes the window bigger by setting the size attribute.
  40.  
  41. • make smaller
  42. Executed when you click on the Smaller button in the Window Examples window.  Makes the window smaller by setting the size attribute.
  43.  
  44.  
  45. CLASS: Menu Examples
  46. There is a special menu that only appears when this window is active.  The menu's title is "Special" and just contains some dummy menu items for demonstrating some of the manipulation of menus that you can do with Prograph.
  47.  
  48. • open window
  49. Executed when you select "Menu Examples" from the Examples menu.  Creates an instance of class "Menu Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  50.  
  51. • Close
  52. Executed when you click on the close box for this window.  Differs from Close in class Window only in that it removes the Special menu before closing the window.
  53.  
  54. • special menu
  55. Executed when the Menu Examples window comes to the front or ceases to be the front window.  Displays or removes the Special menu by setting its active? attribute.
  56.  
  57. • add item
  58. Executed when you click on the Add Item button in the Menu Examples window.  Uses the sc-insert-item primitive to add a new menu item called "New Item" to the end of the Special menu.
  59.  
  60. • set checked
  61. Executed when you click on the "Checked?" check box in the Menu Examples window.  Checks or unchecks the item named "Check Item" in the Special menu by setting the check? attribute.
  62.  
  63. • set name
  64. Executed when you click on the ItemName radio set ("Eeenie", "Meenie", "Miney", "Mo") in the Menu Examples window.  Changes the name of the second item in the Special menu by setting its name attribute.
  65.  
  66. • set enabled
  67. Executed when you click on the "Enabled?" check box in the Menu Examples window.  Enables or disables the entire Special menu by setting its enabled? attribute.
  68.  
  69.  
  70.  
  71. CLASS: Icon Examples
  72.  
  73. • open window
  74. Executed when you select "Icon Examples" from the Examples menu.  Creates an instance of class "Icon Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  75.  
  76. • change icon
  77. Executed when you click on the radio set ("Telephone", "Trash", "People") in the Icon Examples window.  Changes the icon in the window by setting its "rsrc number" attribute.  The 3 icons were specifically added to the Prograph file with resource type 'ICON' and ids 128, 129 and 130 respectively.
  78.  
  79.  
  80. CLASS: Check Box Examples
  81.  
  82. • open window
  83. Executed when you select "Check Box Examples" from the Examples menu.  Creates an instance of class "Check Box Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  84.  
  85. • set enabled
  86. Executed when you click on the "Enabled?" check box in the Check Box Examples window.  Enables or disables the check box in the top left corner of the window by setting its enabled? attribute.
  87.  
  88. • set name
  89. Executed when you click on the radio set ("Example Check Box", "Coffee?", "Tea?", "Me?") in the Check Box Examples window.  Changes the name of the check box in the top left corner of the window by setting its name attribute.
  90.  
  91. • set checked
  92. Executed when you click on the Checked? check box in the Check Box Examples window.  Checks or unchecks the check box in the top left corner of the window by setting its checked? attribute.
  93.  
  94. • also set checked
  95. Executed when you click on the check box in the top left corner of the Check Box Examples window.  Checks or unchecks the Checked? check box by setting its checked? attribute.   (How many times can you say the word "check" in one sentence?!)
  96.  
  97.  
  98. CLASS: Radio Set Examples
  99.  
  100. • open window
  101. Executed when you select "Radio Set Examples" from the Examples menu.  Creates an instance of class "Radio Set Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  102.  
  103. • change value
  104. Executed when you click on the "Change Value" button in the Radio Set Examples window.  Selects the next item in the example radio set by figuring out the index of the current selection, adding 1 to it or wrapping around to index 1 if it's the last item, figuring out the string corresponding to the new index, and setting the value attribute of the petBreeds radio set.
  105.  
  106. • show value
  107. Executed when you click on the "Show Value" button in the Radio Set Examples window.  Gets the value attribute of the petBreeds Radio Set and displays it in a sentence.
  108.  
  109.  
  110. CLASS:  Pop-up Examples
  111.  
  112. • open window
  113. Executed when you select "Pop-up Examples" from the Examples menu.  Creates an instance of class "Pop-up Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  114.  
  115. • set fixed
  116. Executed when you click on the "Fixed?" check box in the Pop-up Examples window.  Makes the example check box have fixed or non-fixed (variable) width by setting its fixed? attribute.
  117.  
  118. • set title
  119. Executed when you click on the "Title?" check box in the Pop-up Examples window.  Makes the example pop-up show or hide its title by setting its title? attribute.
  120.  
  121. • change values
  122. Executed when you click on the radio set ("Colors", "Shapes") in the Pop-up Examples window.  Changes the set of choices displayed in the example pop-up.
  123.  
  124. • display value
  125. Executed whenever you make a new selection in the example pop-up.  Displays the text of the new selection in the edit text above the pop-up.
  126.  
  127. • value as string
  128. Useful method called from "display value".  The value attribute of a pop-up is an index; this method returns the string associated with that index.
  129.  
  130.  
  131.  
  132. CLASS: Scroll List Examples
  133. This window contains two lists, an edit text and a number of buttons.  The list on the left can be edited with the Add, Delete and Change buttons.  The Add button adds whatever is in the edit text to the list.  The Delete button deletes the selected item from the list. The Change button replaces the selected item in the list with whatever is in the Edit Text.  The »Copy» button between the two lists copies the selected item from the first list to the second.
  134.  
  135. • open window
  136. Executed when you select "Scroll List Examples" from the Examples menu.  Creates an instance of class "Scroll List Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  137.  
  138. • copy list value
  139. Executed when you click on the "»Copy»" button in the Scroll List Examples window.  Gets the selected item from the first list and adds it to the end of the second list; does nothing if nothing is selected in the first list.
  140.  
  141. • click list
  142. Executed when you click on the first list.  Uses the wait-double? primitive to see if it was a single or double click.  For single clicks, it displays the selection in the edit text above the list.  For double clicks, it calls the click method of the "»Copy»" button.
  143.  
  144. • add list entry
  145. Executed when you click on the Add button in the Scroll List Examples window.  Adds the text from the Edit Text to the end of the first scroll list.  If there is no text in the Edit Text, does nothing.
  146.  
  147. • delete list entry
  148. Executed when you click on the Delete button in the Scroll List Examples window.  Deletes the currently selected item from the first scroll list.  If there is nothing selected, does nothing.
  149.  
  150. • change list entry
  151. Executed when you click on the Change button in the Scroll List Examples window.   Replaces the currently selected item in the first scroll list with the contents of the Edit Text above it.  If there is no text in the Edit Text, or if nothing is selected in the list, does nothing.
  152.  
  153.  
  154. CLASS: Text Examples
  155. This example just covers the rudiments of text on the Macintosh.  For a much more sophisticated treatment, including multiple styles within a text item and Font, Style, Size and Edit menus that update to reflect the current selection, open and explore the Styled Text.pgs file.
  156.  
  157. • open window
  158. Executed when you select "Text Examples" from the Examples menu.  Creates an instance of class "Text Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  159.  
  160. • paste button
  161. Executed when you click on the Paste button in the Text Examples window.  Calls Menu/Paste, which simply calls the paste-text primitive with the currently selected edit text item from the front window.  Inserts contents of the clipboard at the current text selection.
  162.  
  163. • clear button
  164. Executed when you click on the Clear button in the Text Examples window.  Calls Menu/Clear, which simply calls the clear-text primitive with the currently selected edit text item from the front window.  Deletes current text selection.
  165.  
  166. • cut button
  167. Executed when you click on the Cut button in the Text Examples window.  Calls Menu/Cut, which simply calls the cut-text primitive with the currently selected edit text item from the front window.  Deletes current text selection and places it on the clipboard.
  168.  
  169. • copy button
  170. Executed when you click on the Copy button in the Text Examples window.  Calls Menu/Copy, which simply calls the copy-text primitive with the currently selected edit text item from the front window.  Puts current text selection on the clipboard, but doesn't delete it.
  171.  
  172. • set justification
  173. Executed when you click on the radio set ( "Right" "Left" "Center" ) in the Text Examples window.  Sets the justification attribute of the edit text to the correct Mac Constant corresponding to the radio button selected.
  174.  
  175. • select
  176. Executed when you click on the "select "the"" button in the Text Examples window.  Uses the "in" primitive to search for the next occurrence of "the" after the position of the current selection.  Then sets the selection attribute of the edit text to select the string that was found.
  177.  
  178. • upper
  179. Executed when you click on the Upper button in the Text Examples window.  Converts the currently selected text to uppercase.  Uses the extract-text and insert-text primitives, and the Mac toolbox call UprString.
  180.  
  181. • set size
  182. Executed when you select an item from the Size pop-up in the Text Examples window.  Sets the font size attribute of the edit text based on the pop-up selection.
  183.  
  184. • change font
  185. Executed when you select an item from the Font pop-up in the Text Examples window.  Sets the font attribute of the edit text based on the pop-up selection.  Uses the Mac Toolbox call GetFNum.
  186.  
  187. • change style
  188. Useful utility routine that uses bit operations to add or subtract an individual style component (e.g., bold or italic) into an existing combined style (e.g., bold-italic-underline ).  Sets the font style attribute of the given edit text item.
  189.  
  190. • set bold
  191. Executed when you click on the Bold check box in the Text Examples window.  Calls the change style method to add or subtract bold from the current style of the edit text item.
  192.  
  193. • set italic
  194. Executed when you click on the Italic check box in the Text Examples window.  Calls the change style method to add or subtract italic from the current style of the edit text item.
  195.  
  196. • set underline
  197. Executed when you click on the Underline check box in the Text Examples window.  Calls the change style method to add or subtract underlining from the current style of the edit text item.
  198.  
  199.  
  200. CLASS: Canvas Examples
  201.  
  202. • open window
  203. Executed when you select "Canvas Examples" from the Examples menu.  Creates an instance of class "Canvas Examples" and opens it by calling Window/Open which sets the active? attribute to TRUE.
  204.  
  205. • draw canvas
  206. Executed whenever the canvas needs to be redrawn - i.e., when the window first displays, or when it covered by another window and uncovered again.  Erases the area representing the maximum size of the drawing area of a Canvas, and then draws the contents.  The actual drawing code is semi-complicated, using QuickDraw Mac toolbox calls like FrameOval, LineTo and FrameArc to draw the elements of the face after scaling everything to the current size of the limits (drawing area) of the canvas.  It is not necessary to understand all of the drawing code to understand this example.
  207.  
  208. • change mood
  209. Executed when you click on the "Mood" radio set ("happy", "sad", "smashed").  Forces the canvas to redraw to reflect the new mood.
  210.  
  211. • set limits
  212. Executed when you click on the "Limits" radio set ( "default" "half" "double" "half horizontal" "half vertical" "double horizontal" "double vertical" ).  Sets the limits attribute of the canvas to a new value calculated according to the selection in the radio set.  The limits of a canvas are essentially the drawing area, and the scroll bars update to reflect this.  The draw canvas method scales everything to fit within the current limits.
  213.  
  214. • scroll to end
  215. Executed when you click on the "Scroll To End" button in the Canvas Examples window.  Sets the origin attribute of the canvas in order to make it scroll.
  216.  
  217.  
  218.  
  219. How to Use in Your Program
  220. -------------------------
  221.    Selectively load any method that seems useful.  Most of the methods in this file are useful for learning and for stealing code from, but don't do much on their own.
  222.  
  223.